<?php

class Anotacao{

	private $id;
	private $id_autor;
	private $texto;
	private $data;
	public function __construct($id = 0,$id_autor = 0,$texto= "" ,$data = "0000-00-00 00:00:00"){
		$this->id = $id;
		$this->id_autor = $id_autor;
		$this->texto = $texto;
		$this->data = $data;

	}

	public static function construct($array){
		return new Anotacao( $array['id'], $array['id_autor'], $array['texto'], $array['data']);

	}

	public function getId(){
		return $this->id;
	}

	public function setId($id){
		$this->id=$id;
	}

	public function getId_autor(){
		return $this->id_autor;
	}

	public function setId_autor($id_autor){
		$this->id_autor=$id_autor;
	}

	public function getTexto(){
		return $this->texto;
	}

	public function setTexto($texto){
		$this->texto=$texto;
	}

	public function getData(){
		return $this->data;
	}

	public function setData($data){
		$this->data=$data;
	}
	public function equals($object){
		if($object instanceof Anotacoes){

			if($this->id!=$object->id){
				return false;

			}

			if($this->id_autor!=$object->id_autor){
				return false;

			}

			if($this->texto!=$object->texto){
				return false;

			}

			if($this->data!=$object->data){
				return false;

			}

			return true;

		}
		else{
			return false;
		}

	}
	public function toString(){

		return "  [id:" .$this->id. "]  [id_autor:" .$this->id_autor. "]  [texto:" .$this->texto. "]  [data:" .$this->data. "]  " ;
	}
	public function toArray(){

		$temp =   (array) $this;

		$array = array();

		foreach ($temp as $k => $v){

			$k = preg_match('/^\x00(?:.*?)\x00(.+)/', $k, $matches) ? $matches[1] : $k;

			$array[$k] = $v;


		}
		return  $array;
	}

}

?>